package demo1218.homework;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/*
3.编写程序,创建Collection<Girl>集合并存入3个数据,
运用Collection中的Iterator迭代器遍历集合,并运用增强型for遍历集合。
Girl类中的属性有 name ,age，address.
 */
public class Demo_04 {
    public static void main(String[] args) {
        Collection<Girl> col = new ArrayList<>();
        col.add(new Girl("rose",12,"合肥"));
        col.add(new Girl("jakc",19,"阜阳"));
        col.add(new Girl("tom",18,"上海"));
        Iterator<Girl> it = col.iterator();
        while (it.hasNext()){
            Girl s = it.next();
            System.out.println(s);
        }
        for (Girl girl : col) {
            System.out.println(girl);
        }
    }
}
